package com.ugoodtech.mdcc.web.dto;


import com.ugoodtech.mdcc.core.Constants;
import com.ugoodtech.mdcc.core.domain.Photo;

import java.text.SimpleDateFormat;

/**
 * Copyright © 2013 All Rights Reserved, Ugood Technology, Inc.
 */
public class PhotoResponse {
    private Long photoId;
    private String category;
    private String creationTime;
    private String uploadUser;
    private String description;

    public Long getPhotoId() {
        return photoId;
    }

    public void setPhotoId(Long photoId) {
        this.photoId = photoId;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getCreationTime() {
        return creationTime;
    }

    public void setCreationTime(String creationTime) {
        this.creationTime = creationTime;
    }

    public String getUploadUser() {
        return uploadUser;
    }

    public void setUploadUser(String uploadUser) {
        this.uploadUser = uploadUser;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }


    public static PhotoResponse turnPhotoToResponse(Photo photo) {
        if (null != photo) {
            SimpleDateFormat defaultFormat = new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT);
            PhotoResponse photoResponse = new PhotoResponse();
            photoResponse.setPhotoId(photo.getId());
            if (null != photo.getCreationTime()) {
                photoResponse.setCreationTime(defaultFormat.format(photo.getCreationTime()));
            }

            photoResponse.setDescription(photo.getDescription());
            return photoResponse;
        } else {
            return null;
        }
    }
}
